#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int main(int argc, char **argv)
{
    int fd;
    int ret;
    char buffer[1024];
    int i;

    fd = open(argv[1], O_WRONLY|O_CREAT|O_EXCL, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH);

    if(-1 == fd){
        perror("open error");
        exit(-1);
    }

    ret = lseek(fd, 4096, SEEK_SET);
    if(-1 == ret){
        perror("lseek error");
        goto err;
    }

    memset(buffer, 0xFF, sizeof(buffer));

    for(i=0; i<4; i++){
        ret = write(fd, buffer, sizeof(buffer));
        if(-1 == ret){
            perror("write error");
            goto err;
        }
    }

    ret = 0;

    err:
        close(fd);
        exit(ret);
}
